package com.wijqgrid.demo;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.ResourceReference;
import org.apache.wicket.Session;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
import org.odlabs.wiquery.ui.themes.IThemableApplication;
import org.odlabs.wiquery.utils.WiQueryWebApplication;

import com.wijqgrid.Resources;
import com.wijqgrid.test.Person;


/**
 * Application object for your web application. If you want to run this application without deploying, run the Start class.
 * 
 * @see com.wijqgrid.Start#main(String[])
 */
public class WicketApplication extends WiQueryWebApplication implements IThemableApplication
{    
	
	private static List<Person> persons;
	
    /**
     * Constructor
     */
	public WicketApplication()
	{
	}
	
	/**
	 * @see org.apache.wicket.Application#getHomePage()
	 */
	public Class<? extends WebPage> getHomePage()
	{
		return HomePage.class;
	}
	
	@Override
	protected void init() {
		getDebugSettings().setOutputMarkupContainerClassName(false);
		getMarkupSettings().setStripWicketTags(true);
		super.init();
	}

	public ResourceReference getTheme(Session session) {
		return Resources.CSS_JQUERY_UI;
	}
	
	 public List<Person> getPersons() {
    	if(persons == null) {
    		persons = new ArrayList<Person>();
    		for(int i=0; i<205;i++) {
    			Person person = new Person();
    			person.setId(new Long(i));
    			person.setName("Name-" + i);
    			person.setLastName("LastName-" + i);
    			persons.add(person);
    		}
    	}
    	return persons;
    }
	 
	public static WicketApplication getWicketApplication() {
		return (WicketApplication)WebApplication.get();
	}

}
